package org.viettan.android.main.model;

import java.util.List;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

/**
 * A {@code RadioProgram} is a channel on the RCTM program.
 */
@SuppressWarnings("serial")
public class RadioProgram implements Entity {
    private int id;
    private String title;
    private final List<RadioEpisode> episodes = Lists.newArrayList();
    
    /**
     * Constructs a new {@code RadioProgram}
     */
    public RadioProgram() {
    }

    /**
     * Sets the ID of the RadioProgram.
     * 
     * @param id
     * @return
     */
    public RadioProgram setId(int id) {
	Preconditions.checkArgument(id > 0, "Id must be positive");

	this.id = id;
	return this;
    }

    /**
     * Returns the ID of the RadioProgram.
     */
    public int getId() {
	return id;
    }

    /**
     * Sets the title of the program.
     * 
     * @param title
     * @return
     */
    public RadioProgram setTitle(String title) {
	this.title = title;
	return this;
    }

    /**
     * Returns the title of the program.
     */
    public String getTitle() {
	return title;
    }

    /**
     * Adds an episode to this program.
     * 
     * @param episode
     */
    public void addEpisode(RadioEpisode episode) {
	Preconditions.checkArgument(episode != null, "Episode cannot be null");

	episodes.add(episode);
    }

    /**
     * Returns a list of the individual radio episodes in this program.
     */
    public List<RadioEpisode> getEpisodes() {
	return ImmutableList.copyOf(episodes);
    }

    @Override
    public String toString() {
	return title;
    }
}
